package com.iris.live.services.data.repositories;
import com.iris.live.services.data.models.TFinanceCheckModel;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

/**
 * Created by wzy on 2017/5/18.
 */
public interface FinanceCheckRepository extends JpaRepository<TFinanceCheckModel, Integer>, JpaSpecificationExecutor<TFinanceCheckModel> {

    /**
     * 根据导入批次和车架号查找导入的金融数据
     * @param importBatch 导入批次
     * @param vin 车架号
     * @return 返回
     */
    @Query("select finance from TFinanceCheckModel finance where finance.importBatch = ?1 and finance.vin = ?2")
    TFinanceCheckModel findFinanceByImportBatchAndVin(String importBatch,String vin);

    /**
     * 根据导入批次和导入用户查找导入的金融数据
     * @param importBatch 导入批次
     * @param importUser 导入用户
     * @return 返回
     */
    @Query("select finance from TFinanceCheckModel finance where finance.importBatch = ?1 and finance.importUser =?2")
    List<TFinanceCheckModel> findFinanceByImportBatchAndImportUser(String importBatch,String importUser);

    /**
     * 根据导入车架号查找导入的金融数据
     * @param vin 车架号
     * @return 返回
     */
    @Query("select finance from TFinanceCheckModel finance where finance.vin = ?1")
    TFinanceCheckModel findFinanceByVin(String vin);

    /**
     * 根据导入批次和许可查找导入的金融数据
     * @param importBatch 导入批次
     * @param permit 导入用户
     * @return 返回
     */
    @Query("select finance from TFinanceCheckModel finance where finance.importBatch = ?1 and finance.permit =?2")
    List<TFinanceCheckModel> findFinanceByImportBatchAndPermit(String importBatch,String permit);

}
